<?php

class m_website_documents_Layout extends m_website_documents_LayoutBase
{

	private static $instances;
	
	/**
	 * @return m_website_documents_Layout
	 */
	public static function createNew()
	{
		return new self();
	}
	
	/**
	 * @return m_website_documents_Layout
	 */
	public static function getInstanceByUniqueId($id, $lang = null)
	{
		if(is_null($lang)) $lang = f_core_Context::getInstance()->getLang();
		
		if(!isset(self::$instances[$lang][$id]))
		{
			$cache = f_core_Cache::getInstance();
			
			$key = $cache->getDocumentCacheKey($id, $lang);
			
			if($cache->hasCache($key))
			{
				return $cache->getCacheContent($key);
			}
			
			self::$instances[$lang][$id] = new self($id, $lang);
			
			$cache->putInCache($key, self::$instances[$lang][$id]);
			
			return self::$instances[$lang][$id];			
		}

		return self::$instances[$lang][$id];
	}
	
	// Your code here...
}